/*
 * app.js
 * - Bootstrap the application with any data we need
 * - Check for dependencies like device type, platform version or network connection
 * - Require and open our top-level UI component
 *  
 */

// Bootstrap and check dependencies
if (Ti.version < 1.8 ) {
	alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');	  	
}

// This is a single context application with mutliple windows in a stack
(function() {
	//determine platform and form factor and render approproate components
	var osname = Ti.Platform.osname,
		version = Ti.Platform.version,
		height = Ti.Platform.displayCaps.platformHeight,
		width = Ti.Platform.displayCaps.platformWidth;
	
	var Window;
	if (osname == 'iphone') {
		Window = require('ui/ApplicationWindow');
	}
	else {
		alert('Sorry - this application is only compatible with iPhone');
	}
	
	// Set status bar style
	Titanium.UI.iPhone.statusBarStyle = Titanium.UI.iPhone.StatusBar.TRANSLUCENT_BLACK;
	
	// Display the splash for a few seconds before continuing
	setTimeout(function() {
    	new Window().open();
    	
    	if(Ti.App.Properties.getString('notFirstApplicationStart') == null) {
	    	Ti.UI.createAlertDialog({
	    				message: 'The first thing you should do is to add a new vehicle. ' + 
	    					'You\'ll need at least two fill-ups ' +
	    					'before you can see some results (e.g. fuel consumption and charts). Enjoy!',
	    				ok: 'Ok',
	    				title: 'Beginner Advice!'
	    			}).show();	
	    	Ti.App.Properties.setString('notFirstApplicationStart', true);
    	}
	}, 3200);

})();
